package leetcode.editor.cn;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ShanChuLianBiaoDeJieDian {
    public static ListNode deleteNode(ListNode head, int val) {
        if (head == null) return null;
        if (head.val == val) return head.next;
        // 保存前一个节点
        ListNode pre = head;
        ListNode cur = pre.next;
        while (cur != null) {
            if (cur.val == val) {
                pre.next = cur.next;
            }
            pre = cur;
            cur = cur.next;
        }
        return head;
    }

    public static void main(String[] args) {
        ListNode head = new ListNode(4);
        head.next = new ListNode(5);
        head.next.next = new ListNode(1);
        head.next.next.next = new ListNode(9);
        deleteNode(head, 5);
        Map<Character, Integer> res = new HashMap<>();
        res.put('a', 1);
    }
}
